from functools import wraps
from flask import session, redirect, url_for,g


# def login_required(func):
#     def wrapper(*args, **kwargs):
#         if 'user_id' in session:
#             return func(*args, **kwargs)
#         else:
#             return redirect(url_for('login'))
#
#     return wrapper


# def login_required(func):
#     @wraps(func)
#     def wrapper(*args, **kwargs):
#         if not hasattr(g, 'user_id'):
#             return redirect(url_for('login'))
#         else:
#             return func(*args, **kwargs)
#     return wrapper
